import basegraphunit from './basegraphunit.js'
import coorPkg from '../../struct/coord.js'

class EllipseArc extends basegraphunit.BaseGraphUnit {
    constructor() {
        super();
        this.pos = new coorPkg.EllipseArcPos();
        this.xRadius = 0;
        this.yRadius = 0;
        this.x = 0;
        this.y = 0;
        this.stAngle = 0;//角度值
        this.endAngle = 0;
        this.antiClockWise = true;//默认逆时针绘制
    }

    translateSubInfo(tx,ty){
        this.x += tx;
        this.y += ty;
    }

    toJson() {
        var jsonobj = {};
        super.toJson(jsonobj);
        jsonobj["x"] = this.x;
        jsonobj["y"] = this.y;
        jsonobj["xRadius"] = this.xRadius;
        jsonobj["yRadius"] = this.yRadius;
        jsonobj["stAngle"] = this.stAngle;
        jsonobj["endAngle"] = this.endAngle;
        jsonobj["antiClockWise"] = this.antiClockWise;
        return jsonobj;
    }
    fromJson(obj) {
        super.fromJson(obj);
        this.x = obj["x"];
        this.y = obj["y"];
        this.xRadius = obj["xRadius"];
        this.yRadius = obj["yRadius"];
        this.stAngle = obj["stAngle"];
        this.endAngle = obj["endAngle"];
        this.antiClockWise = obj["antiClockWise"];

        this.pos.x = this.x;
        this.pos.y = this.y;
        this.pos.xRadius = this.xRadius;
        this.pos.yRadius = this.yRadius;
        this.pos.stAngle = this.stAngle;
        this.pos.endAngle = this.endAngle;
        this.pos.antiClockWise = this.antiClockWise;
    }

    cloneCopy() {
        var pNewInfo = new EllipseArc();
        super.cloneCopy(pNewInfo);
        pNewInfo.x = this.x;
        pNewInfo.y = this.y;
        pNewInfo.xRadius = this.xRadius;
        pNewInfo.yRadius = this.yRadius;
        pNewInfo.stAngle = this.stAngle;
        pNewInfo.endAngle = this.endAngle;
        pNewInfo.antiClockWise = this.antiClockWise;
        return pNewInfo;
    }
}

export default { EllipseArc }